<template>
	<view class="select-drop animation-slide-right" v-if="show">
		<view 
			class="select-drop-item u-p-20"
			:class="{'u-border-top': index > 0}"
			:style="{color: currentIndex === index ? infoColorError : ''}"
			v-for="(item, index) in options" 
			:key="index"
			@click="clickItem(index)">{{ item.title }}</view>
	</view>
</template>

<script>
	export default {
		name: 'select-drop',
		props: {
			show: {
				type: Boolean,
				default: false
			},
			size: {
				type: String,
				default: 'medium'
			},
			options: {
				type: Array,
				default () {
					return []
				}
			}
		},
		data() {
			return {
				currentIndex: 0
			}
		},
		mounted() {
		},
		methods: {
			clickItem(index) {
				this.currentIndex = index
				this.hideOptions()
				this.$emit('ok', index)
			},
			hideOptions() {
				this.$emit('close')
			}
		}
	}
</script>

<style scoped>
	.select-drop {
		width: 200rpx;
		background: #fff;
		box-shadow: 0 0 5px rgb(0 0 0 / 10%);
		border-radius: 3px;
		text-align: center;
		position: absolute;
		right: 0;
		top: 66rpx;
		z-index: 9;
	}
</style>
